/*
 *  IBMController.h
 *  
 *
 *  Created by Daniel Condon on 24/08/12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef IBM_GUARD
#define IBM_GUARD

#include "Quadtree.h"
#include <vector>

class IBMController{
private:
	vector<Brain*> objs;
	Quadtree* creatureTree;
	enum TerrainType {GRASS=0, ROCKY=1, URBAN=2};
	//int terrain;
public:
	/*--Default Constructor
	 */
	IBMController();
	
	/*--Main Constructor
	 Params:
	 Parameter(0) : Number of creatures in the area
	 Pre : Parameter(0) not null or negative
	 */
	IBMController(int);
	
	/*--Deconstructor
	 Will attempt to safely delete all creatures
		and tell the quadtree to empty
	 */
	~IBMController();
	
	/*--This function returns the current
	 number of creatures in the area reguardless of state
	 Returns : Total number of creatures
	 */
	int getNumCreatures();
	
	/*--This function returns the current
	 number of creatures in the area reguardless of state
	 Params:
	 Parameter(0) : which creature within the creature array
		(used for quadtree assembly and graphics calls)
	 Pre : specified creature not null and within array bounds
	 Returns : ptr to the specified creature controller
	 */
	Brain* getCreature(int);
	
	/*--This function, for each creature, will retrieve others
		nearby and add them to the nearby array for boid activities
	 */
	void GroupSenses();
	
	/*--This function adds all living creatures to the quadtree,
		Call GroupSenses()
		Call the creatures move function
		Call the creatures infection function
	 */
	void Cycle();
	
	/*--This function will when triggered, infect all creatures in an area
	 Params:
	 Parameter(0) : infection zone centre x coordinate
	 Parameter(1) : infection zone centre y coordinate
	 Pre : Parameter(0&1) are both within the simulation area
	 
	 NOTE : this function is not yet implemented
	 */
	void infectArea(double x, double y);
	
	//DEBUG
	/*--This function returns the full quadtree for debug purposes
	 */
	Quadtree* getTree();
};

#endif